package com.glink.mydemo;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;

import com.baize.glinkad.bean.ads.RewardRewardVideoAD;
import com.baize.glinkad.bean.listener.RewardVideoListener;
import com.baize.glinkad.manager.GLinkADManager;
import com.baize.glinkad.utils.ADLogHelper;


public class VideoActivity extends Activity {
    private Button show_video;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rewardvideo);
        show_video=(Button)findViewById(R.id.show_video);

        final RewardRewardVideoAD rewardRewardVideoAD =new RewardRewardVideoAD(VideoActivity.this,"946297779");
        rewardRewardVideoAD.init();
        rewardRewardVideoAD.setRewardVideoListener(new RewardVideoListener() {
            @Override
            public void onReward() {
                ADLogHelper.info("发放奖励");
            }

            @Override
            public void onReady() {
                ADLogHelper.info("视屏加载完成等待播放");
            }

            @Override
            public void onFail(String code, String msg) {
                ADLogHelper.info(" fail, code: "+code+"    msg:"+msg);
            }

            @Override
            public void onClicked() {
                ADLogHelper.info("点击了视屏");
            }

            @Override
            public void onShow() {
                ADLogHelper.info("播放了视屏");
            }

            @Override
            public void onClose() {
                ADLogHelper.info("关闭视屏");
            }


        });
        rewardRewardVideoAD.load();
        show_video.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (rewardRewardVideoAD.isReady()){
                    rewardRewardVideoAD.show();
                }

            }
        });
    }

    @Override
    protected void onDestroy() {
        GLinkADManager.onDestory(this);
        super.onDestroy();

    }

    @Override
    protected void onResume() {
        GLinkADManager.onResume(this);
        super.onResume();

    }

    @Override
    protected void onPause() {
        GLinkADManager.onPause(this);
        super.onPause();

    }
}
